package cn.im.qywx.wx.component.wakeon;

import cn.im.qywx.model.ImWxUserInfo;
import cn.im.qywx.queue.UserQueue;
import cn.im.qywx.wx.component.Component;
import cn.im.qywx.wx.component.ComponentType;
import cn.im.qywx.wx.component.wakeon.util.Ping;
import cn.im.qywx.wx.util.WriteWeiXinMsgXml;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description: ping服务
 */
@Slf4j
public class PingCom extends Component {
	

	public static Map users = new HashMap<String,String>();
	
	@Override
	public void execute(ImWxUserInfo userInfo) {
		
		String pubStr = null;
		
		String ip = UserQueue.getUsersMap().get(userInfo.getWeixinno());
		
		log.info(ip+"; "+ userInfo.getWeixinno());
		if(Ping.socketConn(ip)){
			pubStr = "您的电脑已开机";
		}else{
			pubStr = "关机 or 正在开机中";
		}

		super.setParams(userInfo, ComponentType.MainMenu,  pubStr, new WriteWeiXinMsgXml());
	}
	
}